package de.dhbw.tinf11b.vfb.tests;

import static org.junit.Assert.*;

import java.util.Date;

import org.junit.Test;

import de.dhbw.tinf11b.vfb.Student;
import de.dhbw.tinf11b.vfb.StudentManager;
import de.dhbw.tinf11b.vfb.exceptions.StudentNotFoundException;

public class StudentManagerTest {

	@Test
	public void testAddStudent() throws StudentNotFoundException {
		String matriculationNumber = "123456";
		
		StudentManager studentManager = StudentManager.getInstance();
		
		studentManager.addStudent("Thomas", "Klytta", "Esslingerstraße 36", "", "thomas@mail.de", new Date(1988, 3, 4), 2007, "Tübingen", 3, "QUIBIQ GmbH", "Leo Martens", matriculationNumber);
		
		Student student = studentManager.getStudentByMatriculationNumber(matriculationNumber);
		assertTrue(student.getMatriculationNumber() == matriculationNumber);
	}

	@Test
	public void testGetStudentByNameAndBirthDate() throws StudentNotFoundException {
		String matriculationNumber = "123456";
		
		StudentManager studentManager = StudentManager.getInstance();
		
		studentManager.addStudent("Thomas", "Klytta", "Esslingerstraße 36", "", "thomas@mail.de", new Date(1988, 3, 4), 2007, "Tübingen", 3, "QUIBIQ GmbH", "Leo Martens", matriculationNumber);
		
		Student student = studentManager.getStudentByNameAndBirthDate("Thomas", "Klytta", new Date(1988, 3, 4));
		assertTrue(student.getMatriculationNumber() == matriculationNumber);
	}
	
	

	@Test
	public void testGetStudentByMatriculationNumber() throws StudentNotFoundException {
		String matriculationNumber = "123456";
		
		StudentManager studentManager = StudentManager.getInstance();
		
		studentManager.addStudent("Thomas", "Klytta", "Esslingerstraße 36", "", "thomas@mail.de", new Date(1988, 3, 4), 2007, "Tübingen", 3, "QUIBIQ GmbH", "Leo Martens", matriculationNumber);
		
		Student student = studentManager.getStudentByMatriculationNumber(matriculationNumber);
		assertTrue(student.getMatriculationNumber() == matriculationNumber);
	}
	@Test
	public void testEditStudent() throws StudentNotFoundException {
		String matriculationNumber = "123456";
		
		StudentManager studentManager = StudentManager.getInstance();
		
		studentManager.addStudent("Thomas", "Klytta", "Esslingerstraße 36", "", "thomas@mail.de", new Date(1988, 3, 4), 2007, "Tübingen", 3, "QUIBIQ GmbH", "Leo Martens", matriculationNumber);
		
		Student student = studentManager.getStudentByNameAndBirthDate("Thomas", "Klytta", new Date(1988, 3, 4));
		
		student.setFirstName("Thommi");
		student.setYearOfAbitur(1967);
		student.setMatriculationNumber("654321");
		assertTrue(student.getFirstName().equals("Thommi"));
		assertTrue(student.getYearOfAbitur()==1967);
		assertTrue(student.getMatriculationNumber().equals("654321"));
	}

}
